import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import UnoCSS from 'unocss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx(), UnoCSS(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  define: {
    // Node.js 全局变量 polyfill
    global: 'globalThis',
    'process.env': {}
  },
  // optimizeDeps: {
  //   // 预构建 sockjs-client
  //   include: ['sockjs-client']
  // },
  server: {
    proxy: {
      '/api': {
        target: 'http://192.168.18.164:8083',
        changeOrigin: true
      },
      '/ws-reminders': {
        target: 'ws://192.168.18.164:8083',
        ws: true
      }
    }
  }
})
